package org.lee.hello;

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.FixedValue;

import static net.bytebuddy.matcher.ElementMatchers.named;

/**
 * @author jackielee
 * @version 1.0
 * @description Demo
 * @date 2021/7/28
 **/
public class Demo {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        String hello = new ByteBuddy()
                .subclass(Object.class)
                .method(named("toString"))
                .intercept(FixedValue.value("Hello ByteBuddy"))
                .make()
                .load(Demo.class.getClassLoader())
                .getLoaded()
                .newInstance()
                .toString();
        System.out.println(hello);
    }
}
